package nieAS.ui {
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.navigateToURL;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.utils.ByteArray;
	import nieAS.utils.Base64;
	
	public class Foot {
		//文件样式
		private static var css:StyleSheet = new StyleSheet();
		
		private static const neteaseLogo:String = "eNoB/gQB+4lQTkcNChoKAAAADUlIRFIAAABfAAAAIwgDAAAAxXImfQAAAMBQTFRF4m90p6amuLe420xS/Pv799vceHV2h4WF+ufnlpWV9MfJwsHC5eXl7ezt1NTUaWZn2tnZ9PP0SEVGWVZX7aep/PPzKCQl6ZWY5oOH1jQ70yQrOjc44N/g8Le6ysnK1Csy2D9FgH5+8r7A4GRp3Vhe77K10M/P7J6h9c/R7quu6IyQ8qWoxcfH43h9bmxsjYuMQj8/Lisrn52eUE1OY2FhMzAxyMfHIx8gr62ukY+Qo6GiXltcc3Fx76+xmZmZ////dKjzuQAAA/lJREFUSMftltuSqjgUhjkERQQREDABBQHRthsFEYOg5v3faifozB7mUD1dTlfNxV4XBhbhC/nXIXL37zXuTr7TfvH/LT/i3v7y1EUwhDAQldf5UhDM6SIbl4vjbNG5ALdb2MC2FSi+zAdJKEeKFKBkN59D5DKfjDZKFnOcvAnkV/kKWpMYuUEUyYBbwLjjw9stzrJMVpDyOn8mhXEU2km2hVIyYz4bxsCWZHnLoe3L+s8ChGQSL5SNG0th1Pk4FIYswkFmv8zfol0yJxlKRAThUw/wxqG5K8a7J94QxgR8CEaPMBGoLT/j2+KcKNDmwrUYy2vI9ABAcmFGuCBB4WO9CXaWJMfTHuGKqZU/78Hf8rcoAjMkcdxChPO3hPJBDGH4JnOiRDgIJTZp6mDLMLHv63rbruqTrp90f4AHQj0mRLvqKSFjvdynYKWf2lOPL4tBCN+IiFDIxVnIvn/tSmARJrYUyzKcP/mYt7Ca4mq/PzR5gT3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kIGRQrcHQpt/120WxitwnlJatIgsW3qZoWCuOtXOtmZ2x8CpvxvsIXQA+EG+GowOAVCJsinkxNEDi5XUbYYnHiA9ira1igKg9/ZGq1QGJi3RZi1VVLhamYkRfuslFVJ+w1VpAlKyMK3RRxKzoSW/yCe5JOGcZFV/e/jKSgMV9NcwXANQbhrWlJgQKLN7lpZui2fVoaWYCVFm2jlHaAvAYt0cTqdsEy+3oKzK3iiEvo8zOFDFS1OCQ8WQpu4+LnooSrXTVoDU60HRlAhde/zRmEkLlYi/Gh2oLeLoggCYCwWQrTgbhE8LzxmmEepsMCUpw3oJbR8q9q2LV4Jfr+B6JFHgInRy/Sv/xP5Z/YfaAf29JCRHZMAAAAASUVORK5CYIJ6NA4D";
		
		//组件
		private static var linkTextField:TextField;
		private static var copyrightTextField:TextField;
		private static var neteasePic:Sprite;
		private static var niePic:Sprite;
		
		public static function get Width():int {
			return 720;
		}
		
		public static function get Height():int {
			return 50;
		}
		
		public static function createFoot(_color:String = "ffffff", _copyrightUri:String = "http://webapi.nie.163.com/comm/foot.php"):Sprite {
			var _sp:Sprite = new Sprite();
			
			linkTextField = new TextField();
			copyrightTextField = new TextField();
			neteasePic = new Sprite();
			niePic = new Sprite();
			
			css.parseCSS(" .stdStyle {color: #" + _color + ";} a:hover {color: #" + _color + ";text-decoration: underline;text-align:left;} a:link {color: #" + _color + ";text-decoration: none;text-align:left;}");
			
			var _copyrightLoader:URLLoader = new URLLoader();
			_copyrightLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
			_copyrightLoader.addEventListener(Event.COMPLETE, function() {
					linkTextField.styleSheet = css;
					linkTextField.htmlText = "<span class='stdStyle'>" + _copyrightLoader.data["link"] + "</span>";
					copyrightTextField.styleSheet = css;
					copyrightTextField.htmlText = "<span class='stdStyle'>" + _copyrightLoader.data["copyright"] + "</span>";
				});
			_copyrightLoader.load(new URLRequest(_copyrightUri));
			
			linkTextField.x = 225;
			linkTextField.y = 8;
			linkTextField.width = 485;
			linkTextField.height = 20;
			linkTextField.selectable = false;
			_sp.addChild(linkTextField);
			copyrightTextField.x = 225;
			copyrightTextField.y = 26;
			copyrightTextField.width = 485;
			copyrightTextField.height = 20;
			copyrightTextField.selectable = false;
			_sp.addChild(copyrightTextField);
			
			var _netease:ByteArray = Base64.decodeToByteArray(neteaseLogo) as ByteArray;
			_netease.uncompress();
			var _neteaseLoader:Loader = new Loader();
			neteasePic.addChild(_neteaseLoader);
			_neteaseLoader.loadBytes(_netease);
			neteasePic.buttonMode = true;
			neteasePic.addEventListener(MouseEvent.CLICK, function() {
					navigateToURL(new URLRequest("http://www.163.com/"));
				});
			neteasePic.x = 11;
			neteasePic.y = 8;
			_sp.addChild(neteasePic);
			
			var _nie:ByteArray = Base64.decodeToByteArray(nieLogo) as ByteArray;
			_nie.uncompress();
			var _nieLoader:Loader = new Loader();
			niePic.addChild(_nieLoader);
			_nieLoader.loadBytes(_nie);
			niePic.buttonMode = true;
			niePic.addEventListener(MouseEvent.CLICK, function() {
					navigateToURL(new URLRequest("http://nie.163.com/"));
				});
			niePic.x = 114;
			niePic.y = 8;
			_sp.addChild(niePic);
			
			return _sp;
		}
	}
}